<template>
  <a-modal
    title="上会信息"
    :visible="true"
    :closable="false"
    centered
    @ok="handleOk"
    @cancel="handleCancel"
    width="600px"
  >
    <div style="width: 100%">
      <a-form-model ref="ruleForm" :model="editMeet" :rules="rules" >
        <a-row :gutter="24">
          <a-col :span="24">
            <a-form-model-item label="上会节点" :label-col="{ span: 6 }" :wrapper-col="{ span: 15 }">
              <a-input placeholder="" v-model="editMeet.timeNodeCode" :disabled="true" />
            </a-form-model-item>
          </a-col>

          <a-col :span="24">
            <a-form-model-item label="主汇报人" ref="mainRemitter" prop="mainRemitter" :label-col="{ span: 6 }" :wrapper-col="{ span: 15 }">
              <a-input placeholder="" v-model="editMeet.mainRemitter" :disabled="onlyShow" 
              @blur="
                () => {
                  $refs.mainRemitter.onFieldBlur()
                }
              "/>
            </a-form-model-item>
          </a-col>

          <a-col :span="24">
            <a-form-model-item label="汇报参与人" ref="joinRemitter" prop="joinRemitter" :label-col="{ span: 6 }" :wrapper-col="{ span: 15 }">
              <a-input placeholder="" v-model="editMeet.joinRemitter" :disabled="onlyShow" 
              @blur="
                () => {
                  $refs.joinRemitter.onFieldBlur()
                }
              "/>
            </a-form-model-item>
          </a-col>

          <a-col :span="24">
            <a-form-model-item label="参会评委" ref="joinCompetition" prop="joinCompetition" :label-col="{ span: 6 }" :wrapper-col="{ span: 15 }">
              <a-input placeholder="" v-model="editMeet.joinCompetition" :disabled="onlyShow" 
              @blur="
                () => {
                  $refs.joinCompetition.onFieldBlur()
                }
              "/>
            </a-form-model-item>
          </a-col>

          <a-col :span="24">
            <a-form-model-item
              :required="true"
              label="实际上会日期"
              :label-col="{ span: 6 }"
              :wrapper-col="{ span: 15 }" 
              ref="realityMeetDate" 
              prop="realityMeetDate"
            >
              <a-date-picker 
                valueFormat='YYYY-MM-DD'
                v-model="editMeet.realityMeetDate"
                :disabled="onlyShow" 
                @blur="
                () => {
                  $refs.realityMeetDate.onFieldBlur()
                }
              "
              />
            </a-form-model-item>
          </a-col>

          <a-col :span="24">
            <a-form-model-item
              :required="true"
              label="评审结果是否同意"
              :label-col="{ span: 6 }"
              :wrapper-col="{ span: 15 }" 
              ref="meetPassed" 
              prop="meetPassed"
            >
              <a-radio-group v-model="editMeet.meetPassed" prop="meetPassed" default-value="" :disabled="onlyShow" 
              @blur="
                () => {
                  $refs.meetPassed.onFieldBlur()
                }
              ">
                <a-radio value=""> 暂无结果 </a-radio>
                <a-radio value="通过"> 通过 </a-radio>
                <a-radio value="不通过"> 不通过 </a-radio>
              </a-radio-group>
            </a-form-model-item>
          </a-col>

          <a-col :span="24">
            <a-form-model-item ref="opinion" prop="opinion" label="评审意见" :label-col="{ span: 6 }" :wrapper-col="{ span: 15 }">
              <a-textarea :disabled="onlyShow" 
                v-model="editMeet.opinion"
                @blur="
                  () => {
                    $refs.opinion.onFieldBlur()
                  }
                "
                :auto-size="{ minRows: 3, maxRows: 5 }"
                style="width: 100%"
                placeholder="请输入评审意见"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </div>
  </a-modal>
</template>
<script>
import { strNotNull } from '@/utils/common.js'
import { getAction, postAction } from '@/api/manage'
export default {
  components: {},
  name: 'ProjectBuildMeet',
  props: {
    meet: {
      type: Object,
      default: {},
    },
    onlyShow: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      editMeet: JSON.parse(JSON.stringify(this.meet)),
      url:{
        updateProjectBuildMeet:'/projectBuild/projectBuildMeet/updateProjectBuildMeet'
      },
      rules: {
        mainRemitter: [
          { min: 1, max: 500, message: '主汇报人不超过个字符500个字符', trigger: 'blur' },
        ],
        joinRemitter: [
          { min: 1, max: 500, message: '汇报参与人不超过个字符500个字符', trigger: 'blur' },
        ],
        joinCompetition: [
          { min: 1, max: 500, message: '参会评委不超过个字符500个字符', trigger: 'blur' },
        ],
        realityMeetDate: [
          { required: true, message: '请选择实际上会日期', trigger: 'blur' },
        ],
        meetPassed:[
          { required: true, message: '请选择评审结果', trigger: 'blur' },
        ],
        opinion:[
          { min: 1, max: 1000, message: '意见不超过1000个字符', trigger: 'blur' },
        ]
        }
    }
  },
  mounted() {},
  methods: {
    handleOk() {
      var vm=this;
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          postAction(this.url.updateProjectBuildMeet,this.editMeet).then(res=>{
            if(res.code==200){
              this.$message.success(res.message);
              setTimeout(function(){
                vm.$emit('close', null)
              },1000);
            }else{
              this.$message.warning('更新上会信息异常:'+res.message);
            }
          }).catch(res=>{
            this.$message.warning('更新上会信息出错:'+res.message);
          });
        } else {
          console.log('submit valid fail!!');
          return false;
        }
      });
    },
    handleCancel() {
      this.$emit('close', null)
    },
  },
}
</script>
<style lang="less" scoped>
/deep/ .ant-transfer-list .ant-btn-primary {
  color: #bbb;
}
/deep/ .ant-transfer-list:first-of-type .ant-transfer-list-header-selected {
  display: none;
}
/deep/ .ant-modal-content {
  border-radius: 15px;
}
/deep/ .ant-modal-title,
/deep/ .ant-modal-footer {
  text-align: center;
}
/deep/ .ant-transfer-operation .ant-btn-primary {
  background-color: #f5f5f5 !important;
}
/deep/ .ant-modal-header {
  border-radius: 15px 15px 0 0;
  background-image: linear-gradient(90deg, #15b1ff 0%, #1158c9 100%);
}
/deep/ .ant-modal-title {
  color: #fff;
}
</style>